// 权限接口管理
import request from "@/utils/request";
import type {
  MenuEditResponse,
  MenuType,
  MenusResponse,
  MenuResponse,
} from "./types";

enum API {
  MENU_LIST = "/menu/list",
  MENU_CREATE_OR_EDIT = "/menu/createOrEdit",
  MENU_REMOVE = "menu/remove",
  MENU_GET_BY_ID = "menu/getById",
}

export const list = () => request.get<any, MenusResponse>(API.MENU_LIST);

export const userCreateOrEdit = (data: MenuType) =>
  request.post<any, MenuEditResponse>(API.MENU_CREATE_OR_EDIT, data);

export const menuRemove = (id: number) =>
  request.delete<any, MenuEditResponse>(API.MENU_REMOVE + `/${id}`);

export const menuGetById = (id: number) =>
  request.get<any, MenuResponse>(API.MENU_GET_BY_ID + `/${id}`);
